<template>
  <div class="dialog" v-show="visible">
    <div class="dialog-wrap">
      <div class="dialog-header">
        <slot name="header" />
        <button class="dialog-header-close" @click="$emit('update:visible',false)">X</button>
      </div>
      <div class="dialog-body">
        <slot>
        </slot>
      </div>
      <div class="dialog-footer">
        <slot name="footer"></slot>
      </div>
    </div>

  </div>

</template>

<script>
export default {
  name: 'Dialog',
  props: {
    visible: {
      type: Boolean, // 数据类型
      required: true // 必须传
    }
  },
  methods: {
    close() {
      this.$emit('update:visible', false);
    }
  }
};
</script>

<style lang="less" scoped>
.qrcode {
  padding-bottom: 30px;
  text-align: center;
}
.dialog {
  // 最外层
  position: fixed;
  left: 0;
  top: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.3);
  // 内层水平垂直居中
  .dialog-wrap {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 430px;
    height: 240px;
    box-sizing: border-box; // 内减模式
    padding: 20px;
    transform: translate(-50%, -50%);
    background-color: #fff;
    .dialog-header {
      font-size: 18px;
      display: flex;
      justify-content: space-between;
      .dialog-header-close {
        padding: 3px 10px;
        border: none;
        border-radius: 3px;
        font-size: 14px;
        cursor: pointer;
        color: #ccc;
        &:hover {
          color: #409eff;
          background-color: red;
        }
      }
    }
    .dialog-body {
      height: 100px;
      // padding-top: 46px;
      text-align: center;
      font-size: 18px;
    }
  }
}
</style>